home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Caml Light 0.61 / Source / src / lib / queue.mli < prev    next >
Encoding:
Text File  |  1993-09-24  |  1.1 KB  |  30 lines  |  [TEXT/MPS ]

  1. (* Queues *)
  2.  
  3. (* This module implements queues (FIFOs), with in-place modification. *)
  4.  
  5. type 'a t mutable;;
  6.         (* The type of queues containing elements of type ['a]. *)
  7.  
  8. exception Empty;;
  9.         (* Raised when [take] is applied to an empty queue. *)
  10.  
  11. value new: unit -> 'a t
  12.         (* Return a new queue, initially empty. *)
  13.   and add: 'a -> 'a t -> unit
  14.         (* [add x q] adds the element [x] at the end of the queue [q]. *)
  15.   and take: 'a t -> 'a
  16.         (* [take q] removes and returns the first element in queue [q],
  17.            or raises [Empty] if the queue is empty. *)
  18.   and peek: 'a t -> 'a
  19.         (* [peek q] returns the first element in queue [q], without removing
  20.            it from the queue, or raises [Empty] if the queue is empty. *)
  21.   and clear : 'a t -> unit
  22.         (* Discard all elements from a queue. *)
  23.   and length: 'a t -> int
  24.         (* Return the number of elements in a queue. *)
  25.   and iter: ('a -> 'b) -> 'a t -> unit
  26.         (* [iter f q] applies [f] in turn to all elements of [q], from the
  27.            least recently entered to the most recently entered.
  28.            The queue itself is unchanged. *)
  29. ;;
  30.